//
//  HomeZhaoDetailViewController.m
//  shuiyun
//
//  Created by 徐双 on 2017/9/8.
//  Copyright © 2017年 qianyi. All rights reserved.
//

#import "HomeZhaoDetailViewController.h"
#import "BoatBeizhuViewCell.h"
#import "BoatDetailViewCell.h"

@interface HomeZhaoDetailViewController ()<UITableViewDelegate,UITableViewDataSource>

@property(nonatomic,strong)UITableView * tableView;



@end

@implementation HomeZhaoDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setTitle:@"招聘详情"];
    
  
    [self setUpTableview];
    
    [self setUpLastView];
    
}

-(void)setUpLastView{
    
    UILabel * label1 = [[UILabel alloc] init];
    [self.view addSubview:label1];
    label1.text = @"发布信息:";
    label1.font = [UIFont systemFontOfSize:17];
    label1.textColor = [UIColor colorWithRed:129/255.0f green:129/255.0f blue:129/255.0f alpha:1];
    [label1 mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.view).with.offset(80);
        make.bottom.equalTo(self.view).with.offset(-5);
        make.width.offset(80);
        make.height.offset(25);
        
    }];
    
    UILabel * label2 = [[UILabel alloc] init];
    [self.view addSubview:label2];
    label2.text = @"2017/07/27 15: 33";
    label2.font = [UIFont systemFontOfSize:17];
    label2.textColor = [UIColor colorWithRed:129/255.0f green:129/255.0f blue:129/255.0f alpha:1];
    [label2 mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(label1.mas_right).with.offset(5);
        make.centerY.equalTo(label1.mas_centerY);
        make.width.offset(400);
        make.height.offset(25);
        
    }];
    
}

-(void)setUpTableview{
    
    
    //初始化tableView
    
    self.tableView = [[UITableView alloc] init];
    self.tableView.frame = CGRectMake(0, 0, DEF_SCREEN_WIDTH, DEF_SCREEN_HEIGHT - 64 - 25);
    
    
    self.tableView.tableFooterView = [[UITableView alloc] initWithFrame:CGRectZero];
    
    self.tableView.backgroundColor = [UIColor whiteColor];
    
    
    self.tableView.estimatedRowHeight = 800;
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    //   self.tableView.estimatedRowHeight = 400;
    self.tableView.separatorStyle = UITableViewCellAccessoryNone;//去掉分割线
    
    
    [self.view addSubview:self.tableView];
    
    [self.tableView registerNib:[UINib nibWithNibName:@"BoatBeizhuViewCell" bundle:nil] forCellReuseIdentifier:@"BoatBeizhuViewCell"];
    
    [self.tableView registerNib:[UINib nibWithNibName:@"BoatDetailViewCell" bundle:nil] forCellReuseIdentifier:@"BoatDetailViewCell"];
}

#pragma mark - ---------- Section的数量 ----------
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 2;
}

#pragma mark - ---------- 每个Section的高度 ----------
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    if (section == 0) {
        
        return 44;
    }else{
    
        return 10;
    
    }
}

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{

    
    if (section == 0) {
        
        UIView * headView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, DEF_SCREEN_WIDTH, 44)];
        
        UIView * blueView = [[UIView alloc] initWithFrame:CGRectMake(0, 15, 4, 16)];
        
        blueView.backgroundColor = getColor(@"3F87F6");
        
        [headView addSubview:blueView];
        
        UILabel * label = [[UILabel alloc] init];
        [headView addSubview:label];
        [label mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(blueView).with.offset(10);
            make.centerY.equalTo(blueView.mas_centerY);
            make.height.offset(20);
            make.width.offset(150);
            
        }];
        
        label.text = @"舟山盛畅海运有限公司";
        label.font = [UIFont systemFontOfSize:14];
        label.textColor = getColor(@"262626");
        
        return headView;
    }
    
    return nil;
}

#pragma mark - ---------- Cell的数量 ----------
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (section == 0) {
        
        return 4;
    }else{
        
        return 1;
        
    }
    
    
}

#pragma mark - ---------- 每个Cell的高度 ----------
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section == 0) {
        
        return 50;
    }else{
    
        return UITableViewAutomaticDimension;
    
    }
    
}

#pragma mark - ---------- 每个Cell的内容 ----------
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    if (indexPath.section == 0) {
        
        BoatDetailViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"BoatDetailViewCell"];
        cell.selectionStyle = UITableViewCellEditingStyleNone;
        if (indexPath.row == 0) {
            
            cell.nameLabel.text = @"姓名";
            cell.contentLabel.text = @"******";
        }else if (indexPath.row == 1){
            
            cell.nameLabel.text = @"联系人";
            cell.contentLabel.text = @"社会王";
        }else if(indexPath.row == 2){
            
            cell.nameLabel.text = @"招聘职位";
            cell.contentLabel.text = @"大副";
            
        }else{
            
            cell.nameLabel.text = @"联系电话";
            cell.contentLabel.text = @"13422351849";
            
        }
        return cell;
        
    }else{
        
      BoatBeizhuViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"BoatBeizhuViewCell"];
        cell.selectionStyle = UITableViewCellEditingStyleNone;
        
        cell.beizhuLabel.text = @"岗位职责描述:";
        cell.beizhuContentLabel.text = @"在鲅鱼圈附近,要求建造时间不超过三年,有意者可以电话联系";
        [cell.beizhuContentLabel sizeToFit];
        
        return cell;
        
        
    }
    
    
}


@end
